{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# PyTorch：自动求导(Autograd)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "在上面的例子里，需要我们手动实现神经网络的前向和后向传播。对于简单的两层网络，手动实现前向、后向传播不是什么难事，但是对于大型的复杂网络就比较麻烦了。 \n",
    "\n",
    "庆幸的是，我们可以使用[自动微分](https://en.wikipedia.org/wiki/Automatic_differentiation)来自动完成神经网络中反向传播的计算。PyTorch中**autograd**包提供的正是这个功能。当使用autograd时，网络前向传播将定义一个**计算图**；图中的节点是tensor，边是函数，这些函数是输出tensor到输入tensor的映射。这张计算图使得在网络中反向传播时梯度的计算十分简单。 \n",
    "\n",
    "这听起来复杂，但是实际操作很简单。如果我们想计算某些的tensor的梯度，我们只需要在建立这个tensor时加入这么一句：`requires_grad=True`。这个tensor上的任何PyTorch的操作都将构造一个计算图，从而允许我们稍后在图中执行反向传播。如果这个tensor`x`的`requires_grad=True`，那么反向传播之后`x.grad`将会是另一个张量，其为`x`关于某个标量值的梯度。\n",
    "\n",
    "有时可能希望防止PyTorch在`requires_grad=True`的张量执行某些操作时构建计算图；例如，在训练神经网络时，我们通常不希望通过权重更新步骤进行反向传播。在这种情况下，我们可以使用`torch.no_grad()`上下文管理器来防止构造计算图。\n",
    "\n",
    "下面我们使用PyTorch的Tensors和autograd来实现我们的两层的神经网络；我们不再需要手动执行网络的反向传播："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0 36571340.0\n",
      "1 42503180.0\n",
      "2 53865712.0\n",
      "3 57161024.0\n",
      "4 42253456.0\n",
      "5 19925168.0\n",
      "6 7085042.0\n",
      "7 2814085.0\n",
      "8 1605472.625\n",
      "9 1175494.25\n",
      "10 949169.5\n",
      "11 792956.25\n",
      "12 672060.875\n",
      "13 574474.0625\n",
      "14 494362.5625\n",
      "15 427843.8125\n",
      "16 372209.25\n",
      "17 325347.3125\n",
      "18 285632.1875\n",
      "19 251718.140625\n",
      "20 222585.5\n",
      "21 197616.8125\n",
      "22 176061.296875\n",
      "23 157286.59375\n",
      "24 140862.28125\n",
      "25 126421.234375\n",
      "26 113701.5625\n",
      "27 102474.765625\n",
      "28 92534.0625\n",
      "29 83699.015625\n",
      "30 75827.375\n",
      "31 68802.734375\n",
      "32 62517.87890625\n",
      "33 56886.125\n",
      "34 51836.04296875\n",
      "35 47293.59375\n",
      "36 43197.8671875\n",
      "37 39500.03125\n",
      "38 36156.20703125\n",
      "39 33127.109375\n",
      "40 30384.4296875\n",
      "41 27892.892578125\n",
      "42 25625.916015625\n",
      "43 23562.59375\n",
      "44 21682.3828125\n",
      "45 19966.796875\n",
      "46 18400.140625\n",
      "47 16969.197265625\n",
      "48 15660.3369140625\n",
      "49 14461.2177734375\n",
      "50 13361.912109375\n",
      "51 12354.501953125\n",
      "52 11429.6669921875\n",
      "53 10579.6640625\n",
      "54 9798.1640625\n",
      "55 9079.640625\n",
      "56 8417.751953125\n",
      "57 7807.7099609375\n",
      "58 7245.70556640625\n",
      "59 6727.41796875\n",
      "60 6249.02392578125\n",
      "61 5807.2451171875\n",
      "62 5399.34912109375\n",
      "63 5021.8486328125\n",
      "64 4672.642578125\n",
      "65 4349.4833984375\n",
      "66 4050.267578125\n",
      "67 3773.06494140625\n",
      "68 3516.180419921875\n",
      "69 3277.956787109375\n",
      "70 3056.99169921875\n",
      "71 2851.86279296875\n",
      "72 2661.43017578125\n",
      "73 2484.6533203125\n",
      "74 2320.3330078125\n",
      "75 2167.5302734375\n",
      "76 2025.4515380859375\n",
      "77 1893.250732421875\n",
      "78 1770.2249755859375\n",
      "79 1655.747314453125\n",
      "80 1549.0592041015625\n",
      "81 1449.65673828125\n",
      "82 1357.0517578125\n",
      "83 1270.7666015625\n",
      "84 1190.2584228515625\n",
      "85 1115.13623046875\n",
      "86 1045.019287109375\n",
      "87 979.5692138671875\n",
      "88 918.4480590820312\n",
      "89 861.4022827148438\n",
      "90 808.202392578125\n",
      "91 758.4765625\n",
      "92 711.970947265625\n",
      "93 668.5076904296875\n",
      "94 627.8189697265625\n",
      "95 589.7342529296875\n",
      "96 554.0932006835938\n",
      "97 520.7138671875\n",
      "98 489.4538879394531\n",
      "99 460.18145751953125\n",
      "100 432.7535400390625\n",
      "101 407.04150390625\n",
      "102 382.95166015625\n",
      "103 360.3585510253906\n",
      "104 339.15472412109375\n",
      "105 319.2629089355469\n",
      "106 300.5992431640625\n",
      "107 283.07769775390625\n",
      "108 266.63348388671875\n",
      "109 251.19082641601562\n",
      "110 236.68798828125\n",
      "111 223.07208251953125\n",
      "112 210.27377319335938\n",
      "113 198.2423553466797\n",
      "114 186.92886352539062\n",
      "115 176.29144287109375\n",
      "116 166.28790283203125\n",
      "117 156.8797149658203\n",
      "118 148.0275115966797\n",
      "119 139.6982421875\n",
      "120 131.861328125\n",
      "121 124.48268127441406\n",
      "122 117.5325698852539\n",
      "123 110.98633575439453\n",
      "124 104.8230972290039\n",
      "125 99.01545715332031\n",
      "126 93.54556274414062\n",
      "127 88.38917541503906\n",
      "128 83.52949523925781\n",
      "129 78.9504165649414\n",
      "130 74.63044738769531\n",
      "131 70.55497741699219\n",
      "132 66.71231079101562\n",
      "133 63.086395263671875\n",
      "134 59.6659049987793\n",
      "135 56.438575744628906\n",
      "136 53.39215087890625\n",
      "137 50.515254974365234\n",
      "138 47.803977966308594\n",
      "139 45.23997497558594\n",
      "140 42.8184814453125\n",
      "141 40.53097915649414\n",
      "142 38.37067794799805\n",
      "143 36.32993698120117\n",
      "144 34.40129089355469\n",
      "145 32.57843017578125\n",
      "146 30.857084274291992\n",
      "147 29.228572845458984\n",
      "148 27.689090728759766\n",
      "149 26.233291625976562\n",
      "150 24.856342315673828\n",
      "151 23.554115295410156\n",
      "152 22.322284698486328\n",
      "153 21.156795501708984\n",
      "154 20.05427360534668\n",
      "155 19.01120948791504\n",
      "156 18.024307250976562\n",
      "157 17.09023094177246\n",
      "158 16.20505142211914\n",
      "159 15.367420196533203\n",
      "160 14.574260711669922\n",
      "161 13.823256492614746\n",
      "162 13.112894058227539\n",
      "163 12.439533233642578\n",
      "164 11.80198860168457\n",
      "165 11.19773006439209\n",
      "166 10.62525463104248\n",
      "167 10.082464218139648\n",
      "168 9.56873893737793\n",
      "169 9.081581115722656\n",
      "170 8.620002746582031\n",
      "171 8.182496070861816\n",
      "172 7.767367362976074\n",
      "173 7.374344825744629\n",
      "174 7.001502990722656\n",
      "175 6.648085594177246\n",
      "176 6.312780857086182\n",
      "177 5.994917392730713\n",
      "178 5.693186283111572\n",
      "179 5.407228946685791\n",
      "180 5.135775566101074\n",
      "181 4.87842321395874\n",
      "182 4.634203910827637\n",
      "183 4.402544975280762\n",
      "184 4.182583808898926\n",
      "185 3.9740097522735596\n",
      "186 3.775972604751587\n",
      "187 3.587850570678711\n",
      "188 3.4094858169555664\n",
      "189 3.240264415740967\n",
      "190 3.0793509483337402\n",
      "191 2.9268341064453125\n",
      "192 2.7816736698150635\n",
      "193 2.644202709197998\n",
      "194 2.513512134552002\n",
      "195 2.389327049255371\n",
      "196 2.2713828086853027\n",
      "197 2.1595816612243652\n",
      "198 2.0532889366149902\n",
      "199 1.9523522853851318\n",
      "200 1.8563318252563477\n",
      "201 1.76519775390625\n",
      "202 1.678668737411499\n",
      "203 1.5963468551635742\n",
      "204 1.5181522369384766\n",
      "205 1.4439353942871094\n",
      "206 1.37338387966156\n",
      "207 1.3063180446624756\n",
      "208 1.242544174194336\n",
      "209 1.1819307804107666\n",
      "210 1.12440025806427\n",
      "211 1.069718360900879\n",
      "212 1.0175883769989014\n",
      "213 0.9681093692779541\n",
      "214 0.9210016131401062\n",
      "215 0.876301646232605\n",
      "216 0.8338702321052551\n",
      "217 0.7935385704040527\n",
      "218 0.755031943321228\n",
      "219 0.7185289859771729\n",
      "220 0.6837629675865173\n",
      "221 0.650659441947937\n",
      "222 0.619239330291748\n",
      "223 0.5893628597259521\n",
      "224 0.560995876789093\n",
      "225 0.5339107513427734\n",
      "226 0.5081254243850708\n",
      "227 0.48366034030914307\n",
      "228 0.4603656530380249\n",
      "229 0.4382898211479187\n",
      "230 0.4172157645225525\n",
      "231 0.397203266620636\n",
      "232 0.37817975878715515\n",
      "233 0.36003148555755615\n",
      "234 0.3427387475967407\n",
      "235 0.32633864879608154\n",
      "236 0.3107123076915741\n",
      "237 0.295825719833374\n",
      "238 0.28166475892066956\n",
      "239 0.2682192325592041\n",
      "240 0.2553781270980835\n",
      "241 0.24320566654205322\n",
      "242 0.23158371448516846\n",
      "243 0.22050319612026215\n",
      "244 0.2099817842245102\n",
      "245 0.20000600814819336\n",
      "246 0.19045811891555786\n",
      "247 0.18139100074768066\n",
      "248 0.1727868765592575\n",
      "249 0.16454175114631653\n",
      "250 0.15672016143798828\n",
      "251 0.14931347966194153\n",
      "252 0.14217187464237213\n",
      "253 0.13543644547462463\n",
      "254 0.1290205419063568\n",
      "255 0.12289105355739594\n",
      "256 0.11706805229187012\n",
      "257 0.11152347922325134\n",
      "258 0.10622677206993103\n",
      "259 0.10121248662471771\n",
      "260 0.09639488160610199\n",
      "261 0.09184329211711884\n",
      "262 0.08749133348464966\n",
      "263 0.08337421715259552\n",
      "264 0.07943490147590637\n",
      "265 0.07568612694740295\n",
      "266 0.07209727168083191\n",
      "267 0.06868228316307068\n",
      "268 0.06544692069292068\n",
      "269 0.06234004721045494\n",
      "270 0.05942526459693909\n",
      "271 0.05662928521633148\n",
      "272 0.0539771169424057\n",
      "273 0.05143904313445091\n",
      "274 0.04902128130197525\n",
      "275 0.04672138765454292\n",
      "276 0.044522449374198914\n",
      "277 0.042427048087120056\n",
      "278 0.04044044017791748\n",
      "279 0.03853950276970863\n",
      "280 0.03673355281352997\n",
      "281 0.03501967713236809\n",
      "282 0.033362798392772675\n",
      "283 0.03180751949548721\n",
      "284 0.030326420441269875\n",
      "285 0.028902266174554825\n",
      "286 0.027564292773604393\n",
      "287 0.02627333253622055\n",
      "288 0.02504904754459858\n",
      "289 0.023882606998085976\n",
      "290 0.0227668397128582\n",
      "291 0.0217141043394804\n",
      "292 0.020699787884950638\n",
      "293 0.0197260994464159\n",
      "294 0.018813833594322205\n",
      "295 0.017942257225513458\n",
      "296 0.017117101699113846\n",
      "297 0.016320539638400078\n",
      "298 0.015570832416415215\n",
      "299 0.014849201776087284\n",
      "300 0.014166586101055145\n",
      "301 0.013513904064893723\n",
      "302 0.012899328954517841\n",
      "303 0.01230370532721281\n",
      "304 0.011738721281290054\n",
      "305 0.01120921690016985\n",
      "306 0.010688317008316517\n",
      "307 0.010199882090091705\n",
      "308 0.009738994762301445\n",
      "309 0.00929604284465313\n",
      "310 0.008875465020537376\n",
      "311 0.00847606174647808\n",
      "312 0.008089202456176281\n",
      "313 0.0077224429696798325\n",
      "314 0.007373676635324955\n",
      "315 0.00704572768881917\n",
      "316 0.006731315050274134\n",
      "317 0.006432804279029369\n",
      "318 0.006142734549939632\n",
      "319 0.005872388835996389\n",
      "320 0.00561504065990448\n",
      "321 0.005365155171602964\n",
      "322 0.0051305461674928665\n",
      "323 0.004906389396637678\n",
      "324 0.004691299982368946\n",
      "325 0.004487497266381979\n",
      "326 0.00429231021553278\n",
      "327 0.004109398927539587\n",
      "328 0.003933446481823921\n",
      "329 0.0037640370428562164\n",
      "330 0.0036052120849490166\n",
      "331 0.0034543657675385475\n",
      "332 0.00330745498649776\n",
      "333 0.0031686718575656414\n",
      "334 0.003037848509848118\n",
      "335 0.0029113460332155228\n",
      "336 0.002791943959891796\n",
      "337 0.0026746545918285847\n",
      "338 0.0025667899753898382\n",
      "339 0.0024617635644972324\n",
      "340 0.0023609502241015434\n",
      "341 0.0022666219156235456\n",
      "342 0.002174191642552614\n",
      "343 0.0020869034342467785\n",
      "344 0.0020042185205966234\n",
      "345 0.0019257650710642338\n",
      "346 0.0018476994009688497\n",
      "347 0.001773801981471479\n",
      "348 0.0017036222852766514\n",
      "349 0.0016384209739044309\n",
      "350 0.0015751855680719018\n",
      "351 0.0015156988520175219\n",
      "352 0.001457954291254282\n",
      "353 0.0014033319894224405\n",
      "354 0.0013527609407901764\n",
      "355 0.0013008699752390385\n",
      "356 0.0012538679875433445\n",
      "357 0.001208125613629818\n",
      "358 0.0011626547202467918\n",
      "359 0.0011210774537175894\n",
      "360 0.0010814856505021453\n",
      "361 0.001043730415403843\n",
      "362 0.0010075871832668781\n",
      "363 0.0009719060035422444\n",
      "364 0.0009382818825542927\n",
      "365 0.0009062659228220582\n",
      "366 0.0008753809379413724\n",
      "367 0.0008467111038044095\n",
      "368 0.0008175850962288678\n",
      "369 0.0007912794244475663\n",
      "370 0.0007645378354936838\n",
      "371 0.000739742536097765\n",
      "372 0.0007151175523176789\n",
      "373 0.0006924965418875217\n",
      "374 0.0006706399144604802\n",
      "375 0.0006503071635961533\n",
      "376 0.0006293422193266451\n",
      "377 0.000609220820479095\n",
      "378 0.0005894693895243108\n",
      "379 0.0005726852687075734\n",
      "380 0.0005554775707423687\n",
      "381 0.0005382738308981061\n",
      "382 0.0005224834894761443\n",
      "383 0.0005064336583018303\n",
      "384 0.000490898615680635\n",
      "385 0.00047765474300831556\n",
      "386 0.00046350949560292065\n",
      "387 0.00045016087824478745\n",
      "388 0.0004366449429653585\n",
      "389 0.0004252709331922233\n",
      "390 0.0004133125767111778\n",
      "391 0.00040158245246857405\n",
      "392 0.0003909878432750702\n",
      "393 0.00037913009873591363\n",
      "394 0.00036945397732779384\n",
      "395 0.0003595189773477614\n",
      "396 0.00035002868389710784\n",
      "397 0.00034069627872668207\n",
      "398 0.00033179251477122307\n",
      "399 0.0003232164599467069\n",
      "400 0.00031483377097174525\n",
      "401 0.0003061107126995921\n",
      "402 0.00029849770362488925\n",
      "403 0.00029052747413516045\n",
      "404 0.0002833003818523139\n",
      "405 0.00027597302687354386\n",
      "406 0.00026953319320455194\n",
      "407 0.0002627552312333137\n",
      "408 0.00025658620870672166\n",
      "409 0.0002503188152331859\n",
      "410 0.00024464799207635224\n",
      "411 0.00023810501443222165\n",
      "412 0.0002328542759642005\n",
      "413 0.0002271351113449782\n",
      "414 0.0002216020948253572\n",
      "415 0.00021584161731880158\n",
      "416 0.00021120808378327638\n",
      "417 0.00020636527915485203\n",
      "418 0.00020136285456828773\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "419 0.00019700356642715633\n",
      "420 0.00019232419435866177\n",
      "421 0.00018832969362847507\n",
      "422 0.00018405595619697124\n",
      "423 0.0001800678001018241\n",
      "424 0.0001760434388415888\n",
      "425 0.00017172269872389734\n",
      "426 0.0001683460286585614\n",
      "427 0.00016448635142296553\n",
      "428 0.00016129731375258416\n",
      "429 0.00015835577505640686\n",
      "430 0.0001550164306536317\n",
      "431 0.00015107729996088892\n",
      "432 0.00014832080341875553\n",
      "433 0.0001448635885026306\n",
      "434 0.00014243439363781363\n",
      "435 0.0001399570028297603\n",
      "436 0.00013665464939549565\n",
      "437 0.00013415161811280996\n",
      "438 0.00013126878184266388\n",
      "439 0.00012902816524729133\n",
      "440 0.0001261321740457788\n",
      "441 0.0001237181422766298\n",
      "442 0.00012141861952841282\n",
      "443 0.0001189551257994026\n",
      "444 0.0001172839110950008\n",
      "445 0.00011483496928121895\n",
      "446 0.00011260794417466968\n",
      "447 0.0001107747302739881\n",
      "448 0.00010866869706660509\n",
      "449 0.00010723875311668962\n",
      "450 0.00010494494199519977\n",
      "451 0.00010318480053683743\n",
      "452 0.00010145656415261328\n",
      "453 9.982420306187123e-05\n",
      "454 9.78979078354314e-05\n",
      "455 9.636655158828944e-05\n",
      "456 9.443679300602525e-05\n",
      "457 9.292743925470859e-05\n",
      "458 9.166698873741552e-05\n",
      "459 8.993602386908606e-05\n",
      "460 8.857819193508476e-05\n",
      "461 8.720922050997615e-05\n",
      "462 8.573532977607101e-05\n",
      "463 8.446996798738837e-05\n",
      "464 8.308322867378592e-05\n",
      "465 8.140435966197401e-05\n",
      "466 8.025298302527517e-05\n",
      "467 7.907998224254698e-05\n",
      "468 7.778486178722233e-05\n",
      "469 7.668836042284966e-05\n",
      "470 7.543421816080809e-05\n",
      "471 7.399344758596271e-05\n",
      "472 7.300482684513554e-05\n",
      "473 7.215936784632504e-05\n",
      "474 7.108809222700074e-05\n",
      "475 7.024898513918743e-05\n",
      "476 6.909813964739442e-05\n",
      "477 6.797931564506143e-05\n",
      "478 6.680986552964896e-05\n",
      "479 6.582740024896339e-05\n",
      "480 6.503534677904099e-05\n",
      "481 6.405257590813562e-05\n",
      "482 6.327959999907762e-05\n",
      "483 6.247769488254562e-05\n",
      "484 6.145135557744652e-05\n",
      "485 6.073684198781848e-05\n",
      "486 5.974169835099019e-05\n",
      "487 5.893296474823728e-05\n",
      "488 5.814871838083491e-05\n",
      "489 5.7401644880883396e-05\n",
      "490 5.66204653296154e-05\n",
      "491 5.56932864128612e-05\n",
      "492 5.4886557336431e-05\n",
      "493 5.430538294604048e-05\n",
      "494 5.377953129936941e-05\n",
      "495 5.315919770509936e-05\n",
      "496 5.264207720756531e-05\n",
      "497 5.17376720381435e-05\n",
      "498 5.0956292398041114e-05\n",
      "499 5.016793875256553e-05\n"
     ]
    }
   ],
   "source": [
    "# 可运行代码见本文件夹中的 two_layer_net_autograd.py\n",
    "import torch\n",
    "\n",
    "device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') \n",
    "\n",
    "# N是批大小；D_in是输入维度；\n",
    "# H是隐藏层维度；D_out是输出维度  \n",
    "N, D_in, H, D_out = 64, 1000, 100, 10\n",
    "\n",
    "# 产生随机输入和输出数据\n",
    "x = torch.randn(N, D_in, device=device)\n",
    "y = torch.randn(N, D_out, device=device)\n",
    "\n",
    "# 产生随机权重tensor，将requires_grad设置为True意味着我们希望在反向传播时候计算这些值的梯度\n",
    "w1 = torch.randn(D_in, H, device=device, requires_grad=True)\n",
    "w2 = torch.randn(H, D_out, device=device, requires_grad=True)\n",
    "\n",
    "learning_rate = 1e-6\n",
    "for t in range(500):\n",
    "\n",
    "    # 前向传播：使用tensor的操作计算预测值y。\n",
    "    # 由于w1和w2有requires_grad=True，涉及这些张量的操作将让PyTorch构建计算图，\n",
    "    # 从而允许自动计算梯度。由于我们不再手工实现反向传播，所以不需要保留中间值的引用。\n",
    "    y_pred = x.mm(w1).clamp(min=0).mm(w2)\n",
    "\n",
    "    # 计算并输出loss，loss是一个形状为()的张量，loss.item()是这个张量对应的python数值\n",
    "    loss = (y_pred - y).pow(2).sum()\n",
    "    print(t, loss.item())\n",
    "    \n",
    "    # 使用autograd计算反向传播。这个调用将计算loss对所有requires_grad=True的tensor的梯度。\n",
    "    # 这次调用后，w1.grad和w2.grad将分别是loss对w1和w2的梯度张量。\n",
    "    loss.backward()\n",
    "\n",
    "\n",
    "    # 使用梯度下降更新权重。对于这一步，我们只想对w1和w2的值进行原地改变；不想为更新阶段构建计算图，\n",
    "    # 所以我们使用torch.no_grad()上下文管理器防止PyTorch为更新构建计算图\n",
    "    with torch.no_grad():\n",
    "        w1 -= learning_rate * w1.grad\n",
    "        w2 -= learning_rate * w2.grad\n",
    "\n",
    "        # 反向传播之后手动置零梯度\n",
    "        w1.grad.zero_()\n",
    "        w2.grad.zero_()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (Spyder)",
   "language": "python3",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": false,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {
    "height": "calc(100% - 180px)",
    "left": "10px",
    "top": "150px",
    "width": "227.797px"
   },
   "toc_section_display": true,
   "toc_window_display": false
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
